package lanbo.cj.lmp.view;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import lanbo.cj.lmp.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.TextView;

/**
 * 结束界面中步骤ListView的Adapter
 * */
public class FinishAdapter extends BaseAdapter {
	private Context mContext;
	public ViewHolder holder = null;
	private List<Map<String,Object>> finList = new ArrayList<Map<String,Object>>();
	private boolean isOk;
	
	
	public FinishAdapter( Context context,List<Map<String,Object>> actList) {
		this.mContext = context;
		this.finList = actList;
	}

	public int getCount() {
		return finList.size();
	}

	public Object getItem(int position) {
		return finList.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		isOk = false;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(R.layout.finish_list, null);
			holder = new ViewHolder();
			holder.mAssrt = (TextView) convertView.findViewById(R.id.finishlist_tx);
			holder.bt_finish = (ImageButton) convertView.findViewById(R.id.bt_finish_item);
			convertView.setTag(holder);
		} else
			holder = (ViewHolder) convertView.getTag();
		final Map<String,Object> map = finList.get(position);
		holder.mAssrt.setText(map.get("buzhou").toString());
		holder.bt_finish.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if(isOk) {
					v.setBackgroundResource(R.drawable.off);
					isOk = false;
				}else {
					v.setBackgroundResource(R.drawable.on);
					isOk = true;
				}
				
			}
		});
		return convertView;
	}
	
	


	class ViewHolder {
		TextView mAssrt;
		ImageButton bt_finish;
	}
}
